package com.hy.controller;


import com.hy.pojo.HotelRequest;
import com.hy.service.TbHotelService;
import lombok.AllArgsConstructor;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huangy
 * @since 2025-04-22
 */
@RestController
@RequestMapping("/tbHotelDO")
@AllArgsConstructor
public class TbHotelController {

    @Autowired
    private  TbHotelService hotelService;




    //同步数据到es
    @GetMapping("/syncData")
    public String syncData() throws Exception {
        hotelService.syncData();
        return "success";
    }

    @GetMapping("/getData")
    public String getData() throws Exception {
        hotelService.getData();
        return "success";
    }


    @GetMapping("/countData")
    public String countData() throws Exception {
        hotelService.countData();
        return "success";
    }

    @GetMapping("/filterData")
    public Map<String, List<String>> filterData() throws Exception {
        return  hotelService.filterData();
    }

    @GetMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody HotelRequest request) throws Exception {
        return  hotelService.filters(request);
    }



}

